package voxietest1.jam;

import voxbox.wrapper.VoxiPoint3d;
import voxbox.wrapper.VoxiScene;

public class BounceScene extends VoxiScene {
	public BounceScene() {
	}

	Paddle paddle; 
	Ball ball;
	World world;
	// z = {-.6, .6}
	
	public void mySetup() {
		world = new World();
		ball = new Ball(world,0,0,0);
		ball.RestartBall();
		paddle = new Paddle(world, 0,0,world.zmax);
		
		world.ball = ball;
		world.paddle = paddle;
	}

	public void myUpdate() {
		ball.myUpdate();
		paddle.Move(scene.mouseDX/500f, scene.mouseDY/500f);
	}

	
	
	public void myDrawTwist() {		
		float twist = scene.mouseX/400.0f;
		
		for (int i=0; i < 40; i++) {
			scene.drawBox(0,0,-1+.05f*i, i*twist, .5f, .5f);
		}
	}
	
		
	public void myDraw() {
		Paddle p = paddle;
		float w = p.width/2f;
		float h = p.height/2f;
		voxi.voxi_drawbox(scene.frame, p.x-w, p.y-h, p.z, p.x+w, p.y+h, p.z, 1, 7);
		voxi.voxi_drawbox(scene.frame, p.x-w*.5f, p.y-h*.5f, p.z, p.x+w*.5f, p.y+h*.5f, p.z, 1, 7);
		ball.myDraw();
		world.myDraw();
		voxi.voxi_printalph(scene.frame,  
				new VoxiPoint3d(-1f, -.8f, 0), //world.xmin, world.ymin, world.zmin),
				new VoxiPoint3d(.2f, 0, 0),
				new VoxiPoint3d(0, .2f, 0),
				7, ball.nbounces + " BOUNCES");
	}


}
